package com.javase;
/*
克隆一个对象，两个对象独立空间
 */
public class MethodParameter {
    public static void main(String[] args) {
        //新建Person对象p
        Person01 p = new Person01();
        //赋值
        p.age = 30;
        p.name = "mark";
        //新建Mytools对象 mytools
        Mytools mytools = new Mytools();
        //调用Mytools类里copyPerson方法给p2传递地址
        Person01 p2 = mytools.copyPerson(p);
        System.out.println("p.age="+p.age+",p.name="+p.name);
        System.out.println("p.age="+p2.age+",p.name="+p2.name);
        System.out.println(p == p2);
    }
}

class Person01 {
    String name;
    int age;
}
class Mytools {
    public Person01 copyPerson(Person01 p){
        //新建Person对象p2
        Person01 p2 = new Person01();
        p2.name = p.name;
        p2.age = p.age;
        //返回p2的地址
        return p2;
    }
}